package cool.taomu.toolkit.kademlia.test

import cool.taomu.toolkit.TaomuGuice
import cool.taomu.toolkit.inter.IFunction
import cool.taomu.toolkit.rpc.thrift.client.module.ThritfTHsHaClientModule
import cool.taomu.toolkit.rpc.thrift.client.service.TaomuThriftTHsHaClient
import cool.taomu.toolkit.service.kademlia.thrift.KademliaService
import cool.taomu.toolkit.service.kademlia.thrift.ServiceEntity
import org.apache.thrift.protocol.TProtocol
import org.junit.jupiter.api.Test

class ClientTest {
	
	@Test
	def void t(){
		var injector = TaomuGuice.createInjector(ThritfTHsHaClientModule)
		var cmap = injector.getInstance(TaomuThriftTHsHaClient)
		cmap.get("a", new IFunction<TProtocol>() {
			override apply(TProtocol input) {
				var client = new KademliaService.Client(input);
				var entity = new ServiceEntity();
				entity.serviceName = "/kademlia/index"
				entity.method = "get"
				println(client.findService(entity));
			}
		})
	}	
}